package cn.javadog.algorithm.e1_100;

/**
 * 移除元素
 * https://leetcode-cn.com/problems/remove-element/
 * @author Sprite
 */
public class Algorithm27 {
	public static void main(String[] args) {
	}


	public int removeElement(int[] nums, int val) {
		if (nums.length == 0) return 0;

		int x = 0;
		for (int i = 0; i < nums.length; i++) {
			if (nums[i] != val){
				nums[x] = nums[i];
				x++;
			}
		}

		return x;
	}
}
